package com.accp.biz.impl;

import com.accp.biz.PersonBiz;
import com.accp.dao.PersonDao;
import com.accp.pojo.Person;


import java.util.List;

public class PersonBizImpl implements PersonBiz {
    private PersonDao personDao;
    public void setPersonDao(PersonDao personDao) {
        this.personDao=personDao;
    }
    @Override
    public boolean add(Person person) {
        return personDao.add(person);
    }

    @Override
    public boolean update(Person person) {
        return personDao.update(person);
    }

    /**
     * 根据id删除员工
     * @param pid
     * @return
     */
    @Override
    public boolean delById(Integer pid) {
        return personDao.delById(pid);
    }


    @Override
    public List<Person> getAll(String className) {
        return personDao.getAll(className);
    }

    @Override
    public Person findById(Integer pid) {
        return personDao.findById(pid);
    }

    /**
     * 根据对象Person删除
     * @param person
     * @return
     */
    @Override
    public boolean deletePerson(Person person) {
        return personDao.deletePerson(person);
    }

    /**
     * 分页查询
     */
    @SuppressWarnings("rawtypes")
    @Override
    public List selectByPage(String className, int pageNo, int pageSize) {
        List list = personDao.selectByPage(className, pageNo, pageSize);
        return list;
    }
    /**
     * 查看下一页
     */
    @Override
    public int searchRecordsNextPage(int pageSize, String className) {
        int total = personDao.totalPage(className);
        int pageNo = total / pageSize;
        if(total % pageSize > 0){
            pageNo++;
        }
        return pageNo;
    }


}
